home *** CD-ROM | disk | FTP | other *** search
- /*
- Copyright © 1991-1995 by TopSoft Inc. All rights reserved.
-
- You may distribute this file under the terms of the TopSoft
- Artistic License, accompanying this package.
-
- This file was developed by George (ty) Tempel in connection with TopSoft, Inc..
- See the Modification History for more details.
-
- Product
- About Box
-
- FILE
- ABResource.c
-
- NAME
- ABResource.c, part of the ABox project source code,
- responsible for handling the AboutBox resource (element) class stuff.
-
- DESCRIPTION
- This file contains defines for the about box modules.
-
- DEVELOPED BY
- George (ty) Tempel netromancr@aol.com
- All code in this file, and its associated header file was
- Created by George (ty) Tempel in connection with the TopSoft, Inc.
- "FilterTop" application development, except where noted.
-
- CARETAKER - George (ty) Tempel <netromancr@aol.com>
- Please consult this person for any changes or suggestions to this file.
-
- MODIFICATION HISTORY
-
- dd mmm yy - xxx - patchxx: description of patch
- 9 June 94 - ty - Initial Version Created
- 20-july-94 - ty - initial version released
- 23-may-95 - ty - changes for compatibility with the CodeWarrior CW6
- release and the associated Universal Headers from Apple:
- most methods that returned references now have "Ref" at
- the end of their methods names to prevent possible collisions
- with datatypes and classes of the same name (older versions
- of the compiler didn't have a problem with this).
-
- */
-
- /*===========================================================================*/
-
- /*======= Segmentation directives ========*/
-
- #ifdef USE_MANUAL_SEGMENTATION
- #pragma segment ty
- #endif
-
- /*============ Header files ==============*/
-
- #include "ABResource.h"
-
- /*=============== Globals ================*/
-
- /*================ CODE ==================*/
-
-
- /*=============================== ABResource::ABResource ================================*/
- ABResource::ABResource(void)
- {
- mResType = kABbadResourceType;
- mResID = 0;
- mResHandle = NULL;
- } // end ABResource
-
-
-
- /*=============================== ABResource::~ABResource ================================*/
- ABResource::~ABResource(void)
- {
- this->ReleaseResource();
-
- } // end ~ABResource
-
-
-
- /*=============================== ABResource::ReleaseResource ================================*/
- OSErr
- ABResource::ReleaseResource(void)
- {
- OSErr error = noErr;
-
- if (this->ResourceHandleRef())
- {
- ::ReleaseResource(this->ResourceHandleRef());
- this->ResourceHandleRef() = NULL;
- error = ::ResError();
- }
- return error;
-
- } // end ReleaseResource
-
-
-
- /*=============================== ABResource::CheckFile ================================*/
- Boolean ABResource::CheckFile(FSSpecPtr fssptr)
- {
- OSErr error = noErr;
- Boolean fileOK = false;
- short oldRefNum = CurResFile();
- short resRefNum;
-
- // begin here...
- //
- if (fssptr)
- {
- // the caller specified a file to use
- resRefNum = ::FSpOpenResFile (fssptr, fsRdPerm);
- error = ResError();
- if (error)
- {
- ::UseResFile (oldRefNum);
- return false;
- } else {
- ::UseResFile (resRefNum);
- } // end if else block
- } // end if block
-
- this->ResourceHandleRef() = ::Get1Resource (this->ResourceTypeRef(), this->ResID());
- error = ::ResError();
- if (this->ResourceHandleRef() && !error)
- fileOK = true;
- else
- fileOK = false;
-
- if (fssptr)
- {
- ::CloseResFile(resRefNum);
- ::UseResFile (oldRefNum);
- } // end if block
-
-
- return fileOK;
- } // end CheckFile
-
-
-
-
- /*=============================== ABResource::Stop ================================*/
- OSErr ABResource::Stop(void)
- {
- // begin here...
- //
- // subclasses can OVERRIDE this method if they wish, but the intent
- // here is to halt whatever is going on and free things up if at all possible
- //
- return this->ReleaseResource();
-
- } // end Stop
-
-
-
-
- /*=============================== ABResource::Initialize ================================*/
- OSErr ABResource::InitializeResource(void)
- {
- OSErr error = noErr;
-
- // begin here...
- //
- // subclasses can override this method if they wish, but the intent
- // here is to perform whatever resource loading/initialize might
- // be required for the object.
- //
- if (this->DoesntHaveResourceHandleRef())
- {
- this->ResourceHandleRef() = ::GetResource (this->ResourceTypeRef(), this->ResID()); /* IM I pg 119 */
- error = ::ResError();
- } else {
- ::LoadResource(this->ResourceHandleRef());
- error = ::ResError();
- } // end if block
-
- if (this->HasResourceHandleRef())
- ::HNoPurge(this->ResourceHandleRef());
-
- error = ::ResError();
- return error;
- } // end InitializeResource
-
-
-
-
- /*=============================== ABResource::GetProperty ================================*/
- OSErr ABResource::GetProperty(ABProperty prop,
- void *ptr,
- long *ptrSize)
- {
- OSErr error = noErr;
- long pSize;
-
- // begin here...
-
- if (!ptr)
- return kABPropertyNullStorage;
-
- switch (prop)
- {
- case kABResourceResType:
- (*(ResType *)ptr) = this->ResourceTypeRef();
- pSize = kABResourceResTypeSize;
- break;
- case kABResourceResID:
- (*(short *)ptr) = this->ResID();
- pSize = kABResourceResIDSize;
- break;
- case kABResourceHandle:
- error = this->InitializeResource();
- (*(Handle *)ptr) = this->ResourceHandleRef();
- pSize = kABResourceHandleSize;
- break;
- default:
- error = kABResourceSuperProperty::GetProperty(prop, ptr, ptrSize);
- break;
- } // end switch block
-
- if (ptrSize && !error)
- *ptrSize = pSize;
- return error;
-
- } // end GetProperty
-
-
-
- /*=============================== ABResource::SetProperty ================================*/
- OSErr ABResource::SetProperty(ABProperty prop,
- void *ptr,
- long ptrSize)
- {
- OSErr error = noErr;
-
- // begin here...
-
- if (!ptr)
- return kABPropertyNullStorage;
-
- switch (prop)
- {
- case kABResourceResType:
- this->ResourceTypeRef() = (*(ResType *)ptr);
- break;
- case kABResourceResID:
- this->ResID() = (*(short *)ptr);
- break;
- case kABResourceHandle:
- this->ResourceHandleRef() = (*(Handle *)ptr);
- break;
- default:
- error = kABResourceSuperProperty::SetProperty(prop, ptr, ptrSize);
- break;
- } // end switch block
-
- return error;
-
- } // end SetProperty
-
-
-
- // end of file.